//package com.flowerclient.app.businessmodule.homemodule.view.adapter.diamond;
//
//import android.content.Context;
//import android.graphics.Color;
//import android.graphics.Paint;
//import android.graphics.Typeface;
//import android.support.annotation.NonNull;
//import android.support.v7.widget.GridLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.text.TextUtils;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//import com.alibaba.android.arouter.launcher.ARouter;
//import com.alibaba.android.vlayout.DelegateAdapter;
//import com.alibaba.android.vlayout.LayoutHelper;
//import com.alibaba.android.vlayout.VirtualLayoutManager;
//import com.bumptech.glide.load.Transformation;
//import com.bumptech.glide.load.resource.bitmap.CenterCrop;
//import com.chad.library.adapter.base.BaseQuickAdapter;
//import com.eoner.baselibrary.utils.ScreenUtils;
//import com.eoner.baselibrary.utils.UtilCollection;
//import com.eoner.baselibrary.utils.ViewTransformUtil;
//import com.eoner.commonbean.banner.BannerNewItemBean;
//import com.eoner.commonbean.product.CommodityOversea;
//import com.eoner.commonbean.product.ProductTag;
//import com.eoner.managerlibrary.router.AroutePath;
//import com.flowerclient.app.R;
//import com.flowerclient.app.businessmodule.homemodule.bean.banner.BannerNewBean;
//import com.flowerclient.app.businessmodule.homemodule.bean.shoplist.ProductHomeMessage;
//import com.flowerclient.app.businessmodule.homemodule.old.EventAdDataCallback;
//import com.flowerclient.app.businessmodule.homemodule.view.holder.HomeViewHolder;
//import com.flowerclient.app.utils.CommonUtil;
//import com.flowerclient.app.widget.PriceIntegralLayout;
//
//import java.util.List;
//
//import jp.wasabeef.glide.transformations.CropCircleWithBorderTransformation;
//import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
//
//
//public class HomePageFooterListAdapter extends DelegateAdapter.Adapter<HomeViewHolder> {
//
//    private int width;
//    private String[] strings;
//    private boolean isShareEarn;
//
//    private Context mContext;
//    private LayoutHelper mLayoutHelper;
//    private VirtualLayoutManager.LayoutParams mLayoutParams;
//    private int mCount = 0;
//    private ProductHomeMessage item;
//    private EventAdDataCallback eventAdDataCallback;
//
//    public void setEventAdDataCallback(EventAdDataCallback eventAdDataCallback) {
//        this.eventAdDataCallback = eventAdDataCallback;
//    }
//
//    public HomePageFooterListAdapter(Context context, LayoutHelper layoutHelper, int count) {
//        this(context, layoutHelper, count, null, null);
//    }
//
//    public HomePageFooterListAdapter(Context context, LayoutHelper layoutHelper, int count, @NonNull VirtualLayoutManager.LayoutParams layoutParams, ProductHomeMessage shCategoryData) {
//        this.mContext = context;
//        this.mLayoutHelper = layoutHelper;
//        this.mCount = count;
//        this.mLayoutParams = layoutParams;
//        this.item = shCategoryData;
//        width = (int)((ScreenUtils.getScreenWidth() - ScreenUtils.dp2px(41))/2f);
//    }
//
//    @Override
//    public LayoutHelper onCreateLayoutHelper() {
//        return mLayoutHelper;
//    }
//
//    @Override
//    protected void onBindViewHolderWithOffset(HomeViewHolder holder, int position, int offsetTotal) {
//    }
//
//    @Override
//    public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        return null;
//    }
//
//    @Override
//    public void onBindViewHolder(HomeViewHolder holder, int position) {
//        if (mLayoutParams != null) {
//            holder.itemView.setLayoutParams(
//                    new VirtualLayoutManager.LayoutParams(mLayoutParams));
//        }
//
//        TextView tvDayTxt = helper.getView(R.id.tv_day_txt);
//        TextView tvDayPrice = helper.getView(R.id.tv_day_price);
//        TextView tvOfficialTxt = helper.getView(R.id.tv_official_txt);
//        TextView tvOfficialPrice = helper.getView(R.id.tv_official_price);
//        TextView tv_coin_deduct = helper.getView(R.id.tv_coin_deduct);
//        TextView tv_activity_tag = helper.getView(R.id.tv_activity_tag);
//
//        //活动文案
//        if (item.getPriceTagBean() != null && !TextUtils.isEmpty(item.getPriceTagBean().getActivity_price_tag())){
//            tv_activity_tag.setText(item.getPriceTagBean().getActivity_price_tag());
//            tv_activity_tag.setVisibility(View.VISIBLE);
//        }else {
//            tv_activity_tag.setVisibility(View.GONE);
//        }
//
//        //日常价
//        if (item.getPriceTagBean() != null && !TextUtils.isEmpty(item.getPriceTagBean().getBase_price_tag())){
//            tvDayTxt.setText(item.getPriceTagBean().getBase_price_tag());
//            if (!TextUtils.isEmpty(item.getDaily_price())){
//                tvDayPrice.setText("¥" + item.getDaily_price());
//                tvDayPrice.setVisibility(View.VISIBLE);
//            }
//            tvDayTxt.setVisibility(View.VISIBLE);
//        }else {
//            tvDayTxt.setVisibility(View.GONE);
//            tvDayPrice.setVisibility(View.GONE);
//        }
//
//        //官方价
//        if (item.getPriceTagBean() != null && !TextUtils.isEmpty(item.getPriceTagBean().getMarket_price_tag())){
//            tvOfficialTxt.setText(item.getPriceTagBean().getMarket_price_tag());
//            if (!TextUtils.isEmpty(item.getMarket_price())){
//                tvOfficialPrice.setText("¥" +item.getMarket_price());
//                tvOfficialPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);
//                tvOfficialPrice.setVisibility(View.VISIBLE);
//            }
//            tvOfficialTxt.setVisibility(View.VISIBLE);
//        }else {
//            tvOfficialTxt.setVisibility(View.GONE);
//            tvOfficialPrice.setVisibility(View.GONE);
//        }
//
//        ImageView imageView =  helper.getView(R.id.iv_goods);
//        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
//        layoutParams.height = width;
//        layoutParams.width = width;
//
//        ViewTransformUtil.glideImageView(mContext,item.getImage(),imageView, new Transformation[]{
//                new RoundedCornersTransformation(ScreenUtils.dp2px(7), 0,
//                        RoundedCornersTransformation.CornerType.TOP)} , R.mipmap.defaults);
//
////        TextView newcomer = helper.getView(R.id.newcomer_price);
//        TextView tvActivityMj = helper.getView(R.id.tv_activity_mj);
//        List<ProductTag> tags =  item.getTags();
//        String new_member_tag = "";//新人标签
//        String present_tag = "";//赠品标签
//        String activity_mj_tag = "";//满减标签
//        String deduction_rate_tag = "";//金币抵扣
//        if (tags != null && tags.size()>0) {
//            for (ProductTag tag : tags) {
//                if ("2".equals(tag.getType())) {
//                    new_member_tag = tag.getName();
//                } else if ("3".equals(tag.getType())) {
//                    activity_mj_tag = tag.getName();
//                } else if ("4".equals(tag.getType())) {
//                    present_tag = tag.getName();
//                } else if ("5".equals(tag.getType())) {
//                    deduction_rate_tag = tag.getName();
//                }
//            }
//        }
//
//        //金币抵扣
//        if (!TextUtils.isEmpty(deduction_rate_tag)){
//            tv_coin_deduct.setText(deduction_rate_tag);
//            tv_coin_deduct.setVisibility(View.VISIBLE);
//        }else {
//            tv_coin_deduct.setVisibility(View.GONE);
//        }
//
//        View rl_video = helper.getView(R.id.rl_video);
//        if(item.isHas_video()){
//            rl_video.setVisibility(View.VISIBLE);
//        }else{
//            rl_video.setVisibility(View.GONE);
//        }
//
//        TextView buy_giveaway = helper.getView(R.id.buy_giveaway);
//        if (!TextUtils.isEmpty(present_tag) && item.getPriceTagBean() != null && !TextUtils.isEmpty(item.getPriceTagBean().getDeduction_rate_tag())
//                && !TextUtils.isEmpty(activity_mj_tag)){
//            buy_giveaway.setVisibility(View.GONE);
//        } else {
//            buy_giveaway.setVisibility(!TextUtils.isEmpty(present_tag)?View.VISIBLE:View.GONE);
//            buy_giveaway.setText(TextUtils.isEmpty(present_tag)?"":present_tag);
//        }
//
//        String country = "",country_logo = "",country_tag = "";
//        CommodityOversea oversea = item.getOversea();
//        if(oversea != null){
//            country = oversea.getCountry_name();
//            country_logo = oversea.getCountry_logo();
//            country_tag = oversea.getTag();
//        }
//
//        TextView overseas_direct_mail_name = helper.itemView.findViewById(R.id.overseas_direct_mail_name);
//        ImageView overseas_direct_mail_icon = helper.itemView.findViewById(R.id.overseas_direct_mail_icon);
//        ImageView iv_store = helper.itemView.findViewById(R.id.iv_store);
//
//
//        if (!TextUtils.isEmpty(country)) {
//            overseas_direct_mail_name.setVisibility(View.VISIBLE);
//            helper.setText(R.id.overseas_direct_mail_name, !TextUtils.isEmpty(country) ? country : "");
//            ((TextView) helper.getView(R.id.overseas_direct_mail_name)).setMaxEms(!TextUtils.isEmpty(country_tag) && "2".equals(country_tag) ? 4 : 20);
//        } else {
//            overseas_direct_mail_name.setVisibility(View.GONE);
//        }
//        if (!TextUtils.isEmpty(country_logo)) {
//            overseas_direct_mail_icon.setVisibility(View.VISIBLE);
//            ViewTransformUtil.glideImageView(mContext, country_logo, overseas_direct_mail_icon,
//                    new CropCircleWithBorderTransformation(0, mContext.getResources().getColor(R.color.white)), R.mipmap.defaults);
//        } else {
//            overseas_direct_mail_icon.setVisibility(View.GONE);
//        }
//        if (!TextUtils.isEmpty(item.getShop_icon())) {
//            iv_store.setVisibility(View.VISIBLE);
//            ViewTransformUtil.glideImageView(mContext,item.getShop_icon(),iv_store,new Transformation[]{new CenterCrop()},R.mipmap.defaults_1);
//        } else {
//            iv_store.setVisibility(View.GONE);
//        }
//
//        helper.setText(R.id.tv_sub_title,item.getTitle());
//        helper.setText(R.id.tv_title,item.getSub_title());
//
//        PriceIntegralLayout ll_price = helper.getView(R.id.ll_price);
//        ll_price.setData(item.getIntegral_price(), item.getPrice());
//        ll_price.floadSize(0.7f);
//
//        TextView tv_bofang = helper.getView(R.id.tv_bofang);
//        tv_bofang.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "fonts/iconfont.ttf"));
//
////        ((TextView)helper.getView(R.id.tv_price_older)).setPaintFlags(Paint. STRIKE_THRU_TEXT_FLAG| Paint.ANTI_ALIAS_FLAG);
//        ImageView ivActivity = helper.getView(R.id.iv_activity);
//
//        ImageView ivTagNew = helper.getView(R.id.iv_tag_new);
//        View ivShouqing = helper.getView(R.id.ll_shouqing);
//        LinearLayout ll_earn = helper.getView(R.id.ll_earn);
//        TextView tv_price = helper.getView(R.id.tv_price);
//        TextView tv_money_earn = helper.getView(R.id.tv_money_earn);
//        LinearLayout ll_double_earn = helper.getView(R.id.ll_double_earn);
//
//
//        if(TextUtils.isEmpty(item.getCommission())||0==Double.valueOf(item.getCommission())){
//            tv_money_earn.setVisibility(View.GONE);
//            ll_double_earn.setVisibility(View.GONE);
//        }else {
//            tv_money_earn.setVisibility(View.VISIBLE);
//            tv_money_earn.setText("赚"+item.getCommission());
//            if (!TextUtils.isEmpty(item.getDouble_commission())&&
//                    Float.parseFloat(item.getDouble_commission())>0){
//                tv_money_earn.setVisibility(View.GONE);
//                ll_double_earn.setVisibility(View.VISIBLE);
//                helper.setText(R.id.tv_double_earn,"赚"+item.getDouble_commission());
//            }else {
//                ll_double_earn.setVisibility(View.GONE);
//            }
//        }
//
//        if (!TextUtils.isEmpty(item.getStock())) {
//            if (Long.valueOf(item.getStock()) <= 0) {
//                ivShouqing.setVisibility(View.VISIBLE);
//            } else {
//                ivShouqing.setVisibility(View.GONE);
//            }
//        }
//
//        //新品上架
//        if(item.isIs_new()){
//            ivTagNew.setVisibility(View.VISIBLE);
//        }else {
//            ivTagNew.setVisibility(View.GONE);
//        }
//
////        if (!TextUtils.isEmpty(new_member_tag)){
////            newcomer.setVisibility(View.VISIBLE);
////            newcomer.setText(new_member_tag);
////            if(item.getFresh_user() != null){
////                helper.setText(R.id.tv_price_now,item.getFresh_user().getPrice());
////            }
////        }else {
////            newcomer.setVisibility(View.GONE);
////        }
//
//        if (!TextUtils.isEmpty(activity_mj_tag)){
//            tvActivityMj.setVisibility(View.VISIBLE);
//            tvActivityMj.setText(activity_mj_tag);
//        }else {
//            tvActivityMj.setVisibility(View.GONE);
//        }
//
//        //会员价
//        TextView tagPriceVip = helper.getView(R.id.tag_vip_price);
//        TextView tvPriceVip = helper.getView(R.id.tv_vip_price);
//        if (item.isShow_vip_price()){
//            tagPriceVip.setVisibility(View.VISIBLE);
//            tvPriceVip.setVisibility(View.VISIBLE);
//            tvPriceVip.setText("¥"+item.getVip_price());
//            tvDayTxt.setVisibility(View.GONE);
//            tvDayPrice.setVisibility(View.GONE);
//            tvOfficialTxt.setVisibility(View.GONE);
//            tvOfficialPrice.setVisibility(View.GONE);
//        }else {
//            tagPriceVip.setVisibility(View.GONE);
//            tvPriceVip.setVisibility(View.GONE);
//        }
//
//        double ratio = 1;
//        if (!TextUtils.isEmpty(item.getImage_width())){
//            ratio = width/Double.parseDouble(item.getImage_width());
//        }
//        if(item.getIconInfo()!=null
//                && !TextUtils.isEmpty(item.getIconInfo().iconHeight)
//                &&!TextUtils.isEmpty(item.getIconInfo().iconWidth)) {
//            int leftMargin = (int) (Integer.parseInt(item.getIconInfo().iconLeftMargin)*ratio);
//            int topMargin = (int) (Integer.parseInt(item.getIconInfo().iconTopMargin)*ratio);
//            int bottomMargin = (int) (Integer.parseInt(item.getIconInfo().iconBottomMargin)*ratio);
//            ViewTransformUtil.glideImageView(mContext,item.getIconInfo().iconImage,ivActivity,R.mipmap.defaults);
//            ivActivity.setVisibility(View.VISIBLE);
//            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ivActivity.getLayoutParams();
//            params.height = (int) (Integer.valueOf(item.getIconInfo().iconHeight)*ratio);
//            params.width = (int) (Integer.valueOf(item.getIconInfo().iconWidth)*ratio);
//            params.addRule(RelativeLayout.ALIGN_BOTTOM,0);
//            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT,0);
//            params.setMargins(0, 0, 0, 0);
//            switch (item.getIconInfo().iconMarginType) {
//                case "1":
//                    params.addRule(RelativeLayout.ALIGN_BOTTOM,R.id.iv_goods);
//                    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//                    params.setMargins(leftMargin, topMargin, 0, bottomMargin);
//                    break;
//                case "2":
//                    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//                    params.setMargins(leftMargin, topMargin, 0, bottomMargin);
//                    break;
//            }
//            ivActivity.setLayoutParams(params);
//        }else {
//            ivActivity.setVisibility(View.GONE);
//        }
//
//        helper.setGone(R.id.share_earn, isShareEarn);
//        if (isShareEarn){
//            ((LinearLayout.LayoutParams)helper.getView(R.id.ll_user).getLayoutParams()).topMargin = 0;
//            ll_price.setPriceTextColor(Color.parseColor("#141922"));
//            TextView title = helper.getView(R.id.tv_sub_title);
//            title.setLines(2);
//            title.setMaxLines(2);
//        }
//
//        helper.itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                ARouter.getInstance().build(AroutePath.COMMODITY_DETAIL_ACTIVITY)
//                        .withString("source_page",strings.length>0?strings[0]:"")
//                        .withString("source_module",strings.length>1?strings[1]:"")
//                        .withString("source_element",strings.length>2?strings[2]:"")
//                        .withString("source_position", helper.getAdapterPosition()-getHeaderLayoutCount()+"")
//                        .withString("id",item.getProduct_id()).navigation();
//            }
//        });
//    }
//
//    @Override
//    public int getItemCount() {
//        return mCount;
//    }
//
//    @Override
//    public int getItemViewType(int position) {
//        return 4;
//    }
//}
